package com.mjlf.nio;

import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.channels.Pipe;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Optional;

/**
 * @ClassName TransferTest
 * @auther mjlf
 * @Date 2019/9/11 14:09
 * @Description TODO
 */
public class TransferTest {

    public static void main(String[] args) throws IOException {
        FileChannel fileChannelRead = FileChannel.open(Paths.get("blala.txt"), StandardOpenOption.READ);
        FileChannel fileChannelWrite = FileChannel.open(Paths.get("blala_copy.txt"), StandardOpenOption.WRITE);

        fileChannelWrite.transferFrom(fileChannelRead, 0, fileChannelRead.size());
//        fileChannelWrite.force(false);
        fileChannelRead.close();
        fileChannelWrite.close();
    }
}
